/**
 * 
 * @class NG.response.ShortestFind
 * @extends Ext.util.Observable
 */
NG.response.ShortestFind = Ext.extend(NG.response.Response, {

	/**
	 * Array of OpenLayers.Geometry.Point
	 */
	coordinates:[],

	constructor: function(config){
		NG.response.ShortestFind.superclass.constructor.call(this, config);
	},
	
	/**
	 * Retrieves coordinates from xml document.
	 * @private
	 * @param {Object} xmlDoc
	 */
	retrieveCoordinates: function (xmlDoc){
		var coordinates = fleegix.xml.parse(xmlDoc, "coordinates").coordinates;
		if (!coordinates) { //önceden yapılmıştı fakat daha sonra gml koyulduğu görüldü, bu eklendi o yüzden
			coordinates = fleegix.xml.parse(xmlDoc, "coordinates")["gml:coordinates"];
		}
		return coordinates;
	},
	
	init: function (xmlData) {
		NG.response.ShortestFind.superclass.init.call(this, xmlData);
		var xmlStr = fleegix.xml.parse(fleegix.xml.createDoc(xmlData), 'string').string;
		var xmlDoc = fleegix.xml.createDoc(xmlStr);
		
		//coordinates
		var coordinates = this.retrieveCoordinates(xmlDoc);
		
		this.coordinates=[];		
		if (Ext.isEmpty(coordinates)) { //There is no shortest find record returned from server
			return;
		}
		
		var coorArray = coordinates.trim().split(" ");
		for (var i = 0 ; i<coorArray.length; i++) {
			var pArray = coorArray[i].split(",");
			var point = new OpenLayers.Geometry.Point(pArray[0], pArray[1]);
			this.coordinates.push(point);
		}
	},
	
	getCoordinates: function (){
		return this.coordinates;
	}
	
});